from bs4 import BeautifulSoup

html_str = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>11111111111111111111111</title>
</head>
<body>
<ul>
    <li id="li1">li1</li>
    <li id="li2">li2</li>
    <li id="li3">li3</li>
</ul>
<ol id="ol1">
    <li id="li11"><a href="https://www.baidu.com">百度</a></li>
    <li id="li22"><a href="https://www.jd.com">京东</a></li>
    <li id="li33"><a href="https://www.taobao.com">淘宝</a></li>
</ol>
<ol id="ol2">
    <li id="li111"><a href="https://www.baidu.com">百度</a></li>
    <li id="li222"><a href="https://www.jd.com">京东</a></li>
    <li id="li333"><a href="https://www.taobao.com">淘宝</a></li>
</ol>

</body>
</html>
"""

soup = BeautifulSoup(html_str, 'lxml')

# print(soup, type(soup))

for li in soup.find_all('li'):
    print(li.attrs['id'])